<template>
    <div>
        <h1>情况一：监视ref定义的基本类型数据</h1>
        <h2>count的值：{{count}}</h2>
        <button @click="addCount">点我count+1</button>
    </div>
</template>

<script setup lang="ts" name="Person">
import {watch, ref} from "vue";
let count = ref(0)
function addCount() {
    count.value += 1
}
// 可以不调，一直监视
const stopWatch = watch(count,(newValue,oldValue)=> {
    console.log(newValue,oldValue)
    if(newValue > 5) {
        stopWatch()
    }
})
</script>

<style scoped>
button {
    margin-right: 10px;
}
</style>
